#include <stdio.h>
struct rational {
int numarator;
int numitor;
};
int cmmdc(struct rational x);
struct rational simplificare (struct rational x);
struct rational adunare(struct rational x, struct rational y);
struct rational imultire(struct rational x, struct rational y);
struct rational impartire(struct rational x, struct rational y);
int main()
{
struct rational x,y;
printf("Introduceti numaratorul pt x:"); scanf("%d",&x.numarator);
printf("Introduceti numitorul pt x:"); scanf("%d",&x.numitor);
printf("Introduceti numaratorul pt y:"); scanf("%d",&y.numarator);
printf("Introduceti numitorul pt y:"); scanf("%d",&y.numitor);
printf("Cmmdc:%d",cmmdc(x));
return 0;
}
int cmmdc(struct rational x)
{
while(x.numarator!=x.numitor)
{
if (x.numarator>x.numitor) x.numarator=x.numarator-x.numitor;
else x.numitor=x.numitor-x.numarator;
return x.numitor;
}
}
struct rational simplificare(struct rational x)
{
struct rational s;
int c;
c=cmmdc(x);
s.numarator=x.numarator/c;
s.numitor=x.numitor/c;
return x;
}
struct rational adunare(struct rational x, struct rational y)
{
struct rational a;
a.numarator=x.numarator*y.numitor+y.numarator*x.numitor;
a.numitor=x.numitor*y.numitor;
return a;
}
struct rational imultire (struct rational x, struct rational y)
{
struct rational p;
p.numarator=x.numarator*x.numarator);
p.numitor=x.numitor*x.numitor;
return p
}
